package com.base.logistics.jdl.bean.order;


import com.base.logistics.jdl.bean.RequestParams;
import com.base.logistics.jdl.util.json.JdlGsonBuilder;

import java.util.ArrayList;
import java.util.List;

/**
 * <pre>
 * 取消下单请求对象
 * </pre>
 * @since 2021-02-19
 */
public class CancelOrderRequestParams extends RequestParams {

    /**
     * 服务域
     */
    private static final String LOP_DN= "express";

    /**
     * code字段
     */
    private static final String CODE_FIELD = "stateCode";

    /**
     * 成功状态码
     */
    private static final Integer SUCCESS_CODE = 1;

    /**
     * API url
     */
    private static final String METHOD = "/OrbLsCancelWaybillInterceptService/cancelOrder";


    /**
     * 取消请求信息对象
     * <pre>
     * 是否必填：是
     * </pre>
     */
    private CancelWaybillInterceptReq cancelRequest;

    CancelOrderRequestParams(CancelWaybillInterceptReq cancelRequest) {
        this.cancelRequest = cancelRequest;
    }

    public static CancelOrderRequestBuilder builder() {
        return new CancelOrderRequestBuilder();
    }

    /**
     * 获取返回状态码字段
     * @return 返回状态码字段
     */
    @Override
    public String getCodeField() {
        return CODE_FIELD;
    }

    /**
     * 获取成功返回状态码
     * @return 成功返回状态码
     */
    @Override
    public Integer getSuccessCode() {
        return SUCCESS_CODE;
    }

    /**
     * 获取请求json数据
     * @return 请求json数据
     */
    @Override
    public String getJsonParams() {
        List<CancelWaybillInterceptReq> list = new ArrayList<>();
        list.add(this.cancelRequest);
        return JdlGsonBuilder.create().toJson(list);
    }

    /**
     * 获取服务域
     * @return 服务域
     */
    @Override
    public String getLopDn(){
        return LOP_DN;
    }

    /**
     * 获取API url
     * @return API url
     */
    @Override
    public String getMethod(){
        return METHOD;
    }

    public CancelWaybillInterceptReq getCancelRequest() {
        return this.cancelRequest;
    }

    public void setCancelRequest(CancelWaybillInterceptReq cancelRequest) {
        this.cancelRequest = cancelRequest;
    }

    public String toString() {
        return "CancelOrderRequestParams(cancelRequest=" + this.getCancelRequest() + ")";
    }

    public boolean equals(final Object o) {
        if (o == this) return true;
        if (!(o instanceof CancelOrderRequestParams)) return false;
        final CancelOrderRequestParams other = (CancelOrderRequestParams) o;
        if (!other.canEqual((Object) this)) return false;
        if (!super.equals(o)) return false;
        final Object this$cancelRequest = this.getCancelRequest();
        final Object other$cancelRequest = other.getCancelRequest();
        if (this$cancelRequest == null ? other$cancelRequest != null : !this$cancelRequest.equals(other$cancelRequest))
            return false;
        return true;
    }

    protected boolean canEqual(final Object other) {
        return other instanceof CancelOrderRequestParams;
    }

    public int hashCode() {
        final int PRIME = 59;
        int result = super.hashCode();
        final Object $cancelRequest = this.getCancelRequest();
        result = result * PRIME + ($cancelRequest == null ? 43 : $cancelRequest.hashCode());
        return result;
    }

    public static class CancelOrderRequestBuilder {
        private CancelWaybillInterceptReq cancelRequest;

        CancelOrderRequestBuilder() {
        }

        public CancelOrderRequestBuilder cancelRequest(CancelWaybillInterceptReq cancelRequest) {
            this.cancelRequest = cancelRequest;
            return this;
        }

        public CancelOrderRequestParams build() {
            return new CancelOrderRequestParams(cancelRequest);
        }

        public String toString() {
            return "CancelOrderRequestParams.CancelOrderRequestBuilder(cancelRequest=" + this.cancelRequest + ")";
        }
    }
}
